﻿#ifndef MENUVO_H
#define MENUVO_H

#include <QObject>
#include "qbaseentity.h"
#include <menu.h>
#include <metavo.h>

class MenuVO : public QBaseEntity
{
    Q_OBJECT
    // 使用 Q_PROPERTY 宏定义属性
    Q_PROPERTY(QString authCode READ getAuthCode WRITE setAuthCode)
    Q_PROPERTY(QList<MenuVO> children READ getChildren WRITE setChildren)
    Q_PROPERTY(QString component READ getComponent WRITE setComponent)
    Q_PROPERTY(uint64_t id READ getId WRITE setId)
    Q_PROPERTY(QString name READ getName WRITE setName)
    Q_PROPERTY(QString path READ getPath WRITE setPath)
    Q_PROPERTY(uint64_t pid READ getPid WRITE setPid)
    Q_PROPERTY(QString redirect READ getRedirect WRITE setRedirect)
    Q_PROPERTY(QString type READ getType WRITE setType)
    Q_PROPERTY(int status READ getStatus WRITE setStatus)
    Q_PROPERTY(MetaVO meta READ getMeta WRITE setMeta)
public:
    MenuVO(QObject *parent = nullptr);
    ~MenuVO();

    QJsonObject toJsonObject(PropertiesType type = AllProperty,QStringList propertyList = QStringList()) const override;
    void fromJsonObject(const QJsonObject &jsonObject) override;

    void fromMenu(const Menu &menu);
    void toMenu(Menu &menu);

    QString getAuthCode() const;
    void setAuthCode(const QString &value);

    QList<MenuVO> getChildren() const;
    void setChildren(const QList<MenuVO> &value);

    QString getComponent() const;
    void setComponent(const QString &value);

    uint64_t getId() const;
    void setId(const uint64_t &value);

    QString getName() const;
    void setName(const QString &value);

    QString getPath() const;
    void setPath(const QString &value);

    uint64_t getPid() const;
    void setPid(const uint64_t &value);

    QString getRedirect() const;
    void setRedirect(const QString &value);

    QString getType() const;
    void setType(const QString &value);

    int getStatus() const;
    void setStatus(int value);

    MetaVO getMeta() const;
    void setMeta(const MetaVO &value);
private:
    QString authCode;/**< 后端权限标识 */
    QList<MenuVO> children; /**< 子菜单 */
    QString component; /**< 组件 */
    uint64_t id; /**< 菜单ID */
    QString name; /**< 菜单名称 */
    QString path; /**< 路由路径 */
    uint64_t pid; /**< 父级ID */
    QString redirect; /**< 重定向地址 */
    QString type; /**< 菜单类型 */
    int status; /**< 菜单状态 */
    MetaVO meta;

};
Q_DECLARE_METATYPE(QList<MenuVO>) //注册到元数据对象
#endif // MENUVO_H
